﻿var SceneEnum = {};
SceneEnum.Maps = "99";
SceneEnum.City = "1";
SceneEnum.Dungeon = "2";
SceneEnum.Wild = "3";

var CitieScene = {};
CitieScene.Tavern  = 1;
CitieScene.Shop    = 2;
CitieScene.house   = 3;
CitieScene.Npc     = 4;


/*场景显示管理列表*/
var GF_SceneMgr = {
    init: function () {
        this.nForm = null;
        
        this.objlist = new Array();
        this.n_cid = null;

        this.txt_title = null;
        
        this.hide();
    },
    show: function () {
        if(this.nForm != null){
            this.nForm.show();
        }
    },
    hide: function () {
        if(this.nForm != null){
            this.nForm.hide();
        }
    },
    update: function (obj) {
        var cid = obj.CID;
        if (this.n_cid == cid){
            return;
        }

        //如果已经有场景,则先释放
        if (this.nForm) {
            this.nForm.destroy();
        }
        GF_ShopItems.hide();

        var sceneBg = srcObj.Ct01bg;
        var scobjs = new Array();

        GF_GameMain.btn_search_monster.hide();
        if(obj.CT.toString() == SceneEnum.Wild){
            //显示搜索怪物按钮
            GF_GameMain.btn_search_monster.show();
            sceneBg = srcObj.Wd01bg;
        }
        else if(obj.CT.toString() == SceneEnum.Maps){
            sceneBg = srcObj.GameMapBg;
        }
        else{
            if (obj.CID == 21){
                //普鲁村,
                sceneBg = srcObj.CtPulubg;
                //加载场景物件
                var txt = new F5Frame.Text().Create({ text:"酒馆", x: 150, y: 280, color: "#15f278", fsize: "16pt" });
                txt.click(this.click_cyposter, {arg1:CitieScene.Tavern });
                scobjs.push(txt);

                var txt = new F5Frame.Text().Create({ text:"道具店", x: 700, y: 400, color: "#15f278", fsize: "16pt" });
                txt.click(this.click_cyposter, {arg1:CitieScene.Shop, arg2:1 });
                scobjs.push(txt);

                var txt = new F5Frame.Text().Create({ text:"村长", x: 610, y: 80, color: "#15f278", fsize: "16pt" });
                txt.click(this.click_cyposter, {arg1:CitieScene.Npc, arg2:1, });
                scobjs.push(txt);
            }
        }

        //场景名称
        this.txt_title = new F5Frame.Text().Create({ text:obj.N, x: 30, y: 80, align: "left", color: "#15f278", fsize: "16pt" });
        //this.txt_title.setText(obj.N);
        //背景
        this.nForm = new F5Frame.Image().Create({x:F5Frame._screenWidth / 2, y:F5Frame._screenHeight / 2, file: sceneBg, zorder: 1});
        this.nForm.appendChild(this.txt_title);

        for(x in scobjs){
            this.nForm.appendChild(scobjs[x]);
        }

        this.show();
    },
    click_cyposter: function (type, value) {
        ajaxMsg(MsgEvent.SendSceneC, type+","+value);
    },
}
